a tool for shared writing and social publishing
1import { makeRouter } from "../lib";
2import { push } from "./push";
3import { createClient } from "@supabase/supabase-js";
4import { Database } from "supabase/database.types";
5import { pull } from "./pull";
6import { getFactsFromHomeLeaflets } from "./getFactsFromHomeLeaflets";
7import { Vercel } from "@vercel/sdk";
8import {
9 get_domain_status,
10 get_leaflet_subdomain_status,
11} from "./domain_routes";
12import { get_leaflet_data } from "./get_leaflet_data";
13import { get_publication_data } from "./get_publication_data";
14import { search_publication_names } from "./search_publication_names";
15import { search_publication_documents } from "./search_publication_documents";
16import { get_profile_data } from "./get_profile_data";
17import { get_user_recommendations } from "./get_user_recommendations";
18import { get_hot_feed } from "./get_hot_feed";
19import { get_document_interactions } from "./get_document_interactions";
20import { get_publication_analytics } from "./get_publication_analytics";
21import { get_publication_subscribers_timeseries } from "./get_publication_subscribers_timeseries";
22
23let supabase = createClient<Database>(
24 process.env.NEXT_PUBLIC_SUPABASE_API_URL as string,
25 process.env.SUPABASE_SERVICE_ROLE_KEY as string,
26);
27
28const VERCEL_TOKEN = process.env.VERCEL_TOKEN;
29const vercel = new Vercel({
30 bearerToken: VERCEL_TOKEN,
31});
32const Env = {
33 supabase,
34 vercel,
35};
36export type Env = typeof Env;
37export type Routes = typeof Routes;
38let Routes = [
39 push,
40 pull,
41 getFactsFromHomeLeaflets,
42 get_domain_status,
43 get_leaflet_subdomain_status,
44 get_leaflet_data,
45 get_publication_data,
46 search_publication_names,
47 search_publication_documents,
48 get_profile_data,
49 get_user_recommendations,
50 get_hot_feed,
51 get_document_interactions,
52 get_publication_analytics,
53 get_publication_subscribers_timeseries,
54];
55export async function POST(
56 req: Request,
57 { params }: { params: Promise<{ command: string }> },
58) {
59 let p = await params;
60 let router = makeRouter(Routes);
61 return router(p.command, req, Env);
62}